<script setup lang="ts">
import { toRefs } from 'vue';

import { ElButton, ElDialog } from 'element-plus';

const props = defineProps({
  isPreviewDialogShow: {
    type: Boolean,
    default: false,
  },
  dataName: {
    default: 'No data has been selected!',
    type: String,
  },
  previewSrc: {
    type: String,
    default: '',
  },
});

const emit = defineEmits(['closePreviewDialog', 'deletePdf']);
const { isPreviewDialogShow, dataName, previewSrc } = toRefs(props);
const src = previewSrc.value;
const closePreviewDialog = () => {
  // console.log('previewSrcvalue=', previewSrc.value);
  emit('closePreviewDialog');
};
</script>

<template>
  <div>
    <ElDialog
      v-model="isPreviewDialogShow"
      width="auto"
      align-center
      @close="closePreviewDialog"
      destroy-on-close
      :show-close="false"
    >
      <template #header="{ titleId, titleClass }">
        <div class="my-header">
          <div class="header-text">
            <h2 :id="titleId" :class="titleClass" style="font-size: 25px">
              {{ dataName }}
            </h2>
          </div>
          <div class="header-button">
            <ElButton
              type="primary"
              @click="closePreviewDialog"
              size="large"
              text
              round
            >
              关闭
            </ElButton>
          </div>
        </div>
      </template>
      <div class="all">
        <iframe style="width: 100%; height: 95%" :src="src"> </iframe>
      </div>
    </ElDialog>
  </div>
</template>

<style scoped>
.my-header {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  height: 40px;
  padding-top: 10px;
  padding-bottom: 5px;
  padding-left: 20px;
  font-size: 30px;
}

:deep(.el-dialog__body) {
  padding-top: 5px;
  padding-bottom: 0;
}

:deep(.el-dialog__footer) {
  padding: 5px;
}

.titleClass {
  width: 200px;
  font-size: 30px;
}

.all {
  position: relative;
  box-sizing: border-box;
  display: flex;
  flex-flow: row nowrap;
  justify-content: center;
  width: 60vw;
  height: 700px;
  padding-top: 5px;
  border: 1 px solid;
}

.page-tool-item {
  padding: 8px 15px;
  padding-left: 10px;
  cursor: pointer;
}

.header-text {
  flex: 2 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.header-button {
  display: flex;
  flex: 1 0 auto;
  justify-content: flex-end;
}
</style>
